package com.qunduikj.sjb.sdk.model.enums;

/**
 * @author PengBin on 2015-06-10
 */
public enum ErrorCode {
    // 利用构造函数传参
    Normal(0,"正常"),
    ParameterNotNull(1,"参数不能为空"),
    ParameterError(14,"参数错误"),
    NorPermission(16,"没有权限"),
    SelectDataFail(10005,"查询数据失败 "),
    NoData(10006,"没有数据"),
    OrderSignIn(20014,"该订单你已录入"),
    OrderBind(20010,"当前订单已经被绑定");


    // 定义私有变量
    private int code;
    private String state;

    private ErrorCode(int code, String state) {
        this.code = code;
        this.state = state;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    @Override
    public String toString() {
        return "CutomOrderStatus{" +
               "code=" + code +
               ", state='" + state + '\'' +
               '}';
    }

    public static String valueOf(int type) {
        ErrorCode CorderStatus[] = ErrorCode.values();
        for (int i = 0; i < CorderStatus.length; i++) {
            ErrorCode cs = CorderStatus[i];
            if (cs.getCode()== type) {
                return cs.getState();
            }
        }
        return "";
    }


    public static ErrorCode getByCode(int type) {
        ErrorCode status[] = ErrorCode.values();
        for (int i = 0; i < status.length; i++) {
            ErrorCode cos = status[i];
            if (cos.getCode() == type) {
                return cos;
            }
        }
        return Normal;
    }

}
